Code Selection Techniques: Pattern Matching, Tree Parsing, and Inversion of Derivors
نویسندگان
چکیده
Significant progress in the area of formal tools to support the construction of code generators in recent years has come along with a severe terminological confusion. Closely related techniques appear in different styles, further obscured by ad-hoc extensions. We try to alleviate this situation by suggesting that the code selection task should be understood as the problem of inversion of a hierarchic derivor. This understanding leads to several interesting generalizations. More expressive formalisms heterogeneous tree languages, regular tree languages, derivor images can be used to define the code selectors input language. In all cases, we retain the ability to decide the completeness of the code selector specification as a side-effect of code selector generation. The extension to nonlinear matching, in combination with matching relative to a subsignature M with a nonmvial equational theory, allows to express the non-syntactic conditions formerly associated with a production in a Graham-GlanviUe style code generator description. Due to space restrictions, such extensions can only be sketched here, while the emphasis of this paper lies on motivating and demonstrating our reformulation of the classical pattern matching approach to code generation.
منابع مشابه
Efficient Retargetable Code Generation Using Bottom-up Tree Pattern Matching
Instruction selection is the primary task in automatic code generation. This paper proposes a practical system for performing optimal instruction selection based on tree pattern matching for expression trees. A significant feature of the system is its ability to perform code generation without requiring cost analysis at code generation time. The target machine instructions are specified as attr...
متن کاملCode Selection by Tree Series Transducers
In this paper we model code selection by tree series transducers. We are given an intermediate representation of some compiler as well as a machine grammar with weights, which reflect the number of machine cycles of the instructions. The derivations of the machine grammar are machine codes. In general, a machine grammar is ambiguous and hence there might exist more than one derivation of an int...
متن کاملA Fast General Parser for Automatic Code Generation
The code generator in a compiler attempts to match a subject tree against a collection of tree-shaped patterns for generating instructions. Tree-pattern matching may be considered as a generalization of string parsing. We propose a new generalized LR (GLR) parser, which extends the LR parser stack with a parser cactus. GLR explores all plausible parsing steps to find the least-cost matching. GL...
متن کاملA generic parser for strings and trees
In this paper, we propose a two fold generic parser. First, it simulates the behavior of multiple parsing automata. Second, it parses strings drawn from either a context free grammar, a regular tree grammar, or from both. The proposed parser is based on an approach that defines an extended version of an automaton, called positionparsing automaton (PPA) using concepts from LR and regular tree au...
متن کاملA new algorithm for linear regular tree pattern matching
We consider the problem of linear regular tree pattern matching and describe a new solution based on a bottom up technique. Current bottom up techniques preprocess the patterns and construct a nite state tree pattern matching automaton for the purpose. Though matching time is linear in the size of the subject tree, the size of the automaton can be exponential in the sum of the sizes of all patt...
متن کامل